home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / bsd / net / tokendefs.h < prev   
Text File  |  1995-02-14  |  3KB  |  127 lines

  1. /*     Copyright (c) 1991 NeXT Computer, Inc.  All rights reserved. 
  2.  *
  3.  * tokendefs.h - Token-Ring MAC header definitions.  
  4.  *
  5.  * HISTORY
  6.  * 8-Oct-92  Joel Greenblatt at NeXT
  7.  *     created 
  8.  */
  9.  
  10. #import <sys/errno.h>
  11.  
  12. /*
  13.  * Token ring address - 6 octets
  14.  */
  15. #define NUM_TR_ADDR_BYTES    6
  16.  
  17. struct token_addr {
  18.     u_char    token_addr_octet[NUM_TR_ADDR_BYTES];
  19. };
  20.  
  21. #define ta_byte token_addr_octet
  22.  
  23. typedef struct token_addr token_addr_t;
  24.  
  25. /*
  26.  * MAC header size
  27.  */
  28. #define MAC_HDR_MIN    (1+1+6+6)        /* MAC hdr size w/o ri field */
  29. #define MAC_HDR_MAX    (MAC_HDR_MIN + RISIZE)     /* MAC hdr size w/max ri */
  30.  
  31. /*
  32.  * The maximum size of the MAC information field as spec'd by ISO 8802/5.
  33.  */
  34. #define MAC_INFO_4MB    4472    /* max size of mac info field -- 4 Mbs */
  35. #define MAC_INFO_16MB    17800    /* max size of mac info field -- 16 Mbs */
  36.  
  37. /*
  38.  * Maximum DMA packet sizes for 4 & 16 Mbit assuming no CRC.
  39.  */ 
  40. #define MAC_DMA_MAX_4MB      (MAC_HDR_MAX + MAC_INFO_4MB)
  41. #define MAC_DMA_MAX_16MB  (MAC_HDR_MAX + MAC_INFO_16MB)
  42.  
  43. /* 
  44.  * Routing control field.
  45.  */
  46. typedef struct    {
  47.  
  48. #if    __BIG_ENDIAN__
  49.        unsigned char bcast  : 3,        /* broadcast */
  50.                 len    : 5;        /* length */
  51.        unsigned char dir    : 1,        /* direction */
  52.                 longf  : 3,        /* longest frame */
  53.                 rsrvd  : 4;        /* reserved */
  54.  
  55. #elif    __LITTLE_ENDIAN__
  56.       unsigned char  len    : 5,        /* length */
  57.                     bcast  : 3;        /* broadcast */
  58.       unsigned char  rsrvd  : 4,        /* reserved */
  59.                 longf  : 3,        /* longest frame */
  60.                 dir    : 1;        /* direction */
  61. #else
  62.    error
  63. #endif
  64. } routing_ctl_t;        
  65.  
  66. /* bcast field ... */
  67. #define  BI_SPECIFIC    0    /* b'0xx': non-broadcast (specific route) */
  68. #define  BI_AR_BCAST    4    /* b'10x': all-routes broadcast */
  69. #define  BI_SR_BCAST     6    /* b'11x': single-route broadcast */
  70.  
  71. /* 
  72.  * longf field 
  73.  */
  74. #define  LF_S516    0
  75. #define  LF_S1500    1
  76. #define  LF_S2052    2
  77. #define  LF_S4472    3
  78. #define  LF_S8144    4
  79. #define  LF_S11407    5
  80. #define  LF_S17800    6
  81. #define  LF_BCAST    7    /* All-routes broadcast */
  82.  
  83. #define LFB_4MB        LF_S4472    /* encoded max info -- 4 Mb */
  84. #define LFB_16MB    LF_S17800    /* encoded max info -- 16 Mb */
  85.  
  86. /*
  87.  * Source Routing field (2-18 bytes, must be even)
  88.  */
  89.  
  90. #define RISIZE         18    /* max size (bytes) of 802.5 routing field */
  91.  
  92. typedef    struct    {
  93.     routing_ctl_t    rc;             
  94.     u_char         sn[RISIZE-sizeof(routing_ctl_t)];   
  95. } sroute_t;
  96.  
  97. /*
  98.  * Token Ring MAC header  (IEEE 802.5, ISO 8802/5)
  99.  */
  100.  
  101. #define TR_DA_SIZE    6
  102.  
  103. typedef    struct    {
  104.     u_char         ac;        /* PPPTMRRR;  PPP = token priority */
  105.     u_char         fc;        /* FFrrZZZZ;  FF = frame type */
  106. #define    TR_FC_MASK     0xc0        /* mask for frame-type */
  107. #define    TR_FC_MAC     0x00        /* frame-type = mac frame */
  108. #define    TR_FC_DATA     0x40        /* frame-type = non-mac (data frame) */
  109.     u_char         da[TR_DA_SIZE];    /* destination address */
  110.     u_char         sa[TR_DA_SIZE];    /* source address */
  111. #define TR_RII        0x80        /* routing info indicator bit */
  112.     sroute_t     ri;        /* routing information field */
  113. } tokenHeader_t;
  114.  
  115. /*
  116.  * token-ring netif definitions
  117.  */
  118. #define IFTYPE_TOKENRING    "4/16Mb Token-Ring"    /* netif type-string */
  119.  
  120. /*
  121.  * Error codes
  122.  */
  123. #define    TRINGDOWN    ENETDOWN     // interface down
  124. #define TNOBUFS        ENOBUFS     // transmit queue full error
  125. #define TBADDA        EINVAL         // bad dest addr
  126. #define TBADFSIZE    EMSGSIZE     // bad frame size
  127.